using System;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using AvaloniaEdit.CodeCompletion;
using AvaloniaEdit.Document;
using AvaloniaEdit.Editing;

namespace LuckyCoding.Edit;

public class CompletionData : ICompletionData
{
    public CompletionData(string text)
    {
        Text = text;
    }

    public IImage? Image => null;

    public string Text { get; }

    // Use this property if you want to show a fancy UIElement in the list.
    public object Content => Text;

    public object Description => "Description for " + Text;

    public double Priority { get; } = 0;

    public void Complete(TextArea textArea, ISegment completionSegment,
        EventArgs insertionRequestEventArgs)
    {
        textArea.Document.Replace(completionSegment, Text);
    }
}